﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A5Lib
{
    /// <summary>
    /// Use CreateDateTimePair to make new instances of this object.
    /// </summary>
    [Serializable]
    public class DateTimePair
    {
        public DateTime d1 { get; private set; }
        public DateTime d2 { get; private set; }
        
        
        private DateTimePair()
        {
        }

        /// <summary>
        /// Creates a datetimepair consisting of two datetime objects.
        /// </summary>
        /// <param name="d1"></param>
        /// <param name="d2"></param>
        /// <returns>Returns null if d1.TimeOfDay >= d2.TimeOfDay. Else returns new DateTimePair object.</returns>
        public static DateTimePair CreateDateTimePair(DateTime d1, DateTime d2)
        {
            if (d1.TimeOfDay.CompareTo(d2.TimeOfDay) >= 0) return null;
            else
            {
                DateTimePair dtp = new DateTimePair();
                dtp.d1 = d1;
                dtp.d2 = d2;
                return dtp;
            }
        }
    }
}
